//
//  writeStepsViewController.m
//  ForengnMenu
//
//  Created by wenzhaoxu on 16/1/20.
//  Copyright © 2016年 余旺. All rights reserved.
//

#import "writeStepsViewController.h"

@interface writeStepsViewController ()

@property UITextView * textView;

@end

@implementation writeStepsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    UIButton * leftBnt = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftBnt setTitle:@"取消" forState:UIControlStateNormal];
    [leftBnt setTitleColor:[UIColor colorWithRed:248/255.0f green:102/255.0f blue:79/255.0f alpha:1.0f] forState:UIControlStateNormal];
    
    leftBnt.titleLabel.font = [UIFont systemFontOfSize:16];
    
    leftBnt.frame = CGRectMake(0, 0, 35, 30);
    
    [leftBnt addTarget:self action:@selector(editAction) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBnt];
    
    UIButton * rightBnt = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBnt setTitle:@"保存" forState:UIControlStateNormal];
    [rightBnt setTitleColor:[UIColor colorWithRed:248/255.0f green:102/255.0f blue:79/255.0f alpha:1.0f] forState:UIControlStateNormal];
    
    rightBnt.titleLabel.font = [UIFont systemFontOfSize:16];
    
    rightBnt.frame = CGRectMake(0, 0, 35, 30);
    
    [rightBnt addTarget:self action:@selector(saveAction) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBnt];
    
    _textView = [[UITextView alloc]initWithFrame:CGRectMake(10, 65, 300, 220)];
    
    _textView.font = [UIFont systemFontOfSize:16];
    
    _textView.textAlignment = NSTextAlignmentNatural;
    
    [self.view addSubview:_textView];
    
}
-(void)editAction{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
//定义一个方法
- (void)changeWithTitle:(NSString *)title withBlock:(SaveContentBlock)block{
    
    self.myBlock = block;
    
}
-(void)saveAction{
    
    if (self.myBlock) {
        self.myBlock(_textView.text);
    }
    
    [self.navigationController popViewControllerAnimated:YES];
}

@end
